package com.contextor.cards.shell.main
{
	import by.typing.vkontakte.wrapper.Wrapper;
	
	import com.contextor.cards.shell.core.APIModel;
	import com.contextor.cards.shell.core.apievents.AppReadyToStartEvent;
	import com.contextor.cards.shell.core.apievents.InitAPIEvent;
	
	import mx.controls.Alert;
	import mx.core.FlexGlobals;

	public class MainController
	{
		[Inject]
		public var apiModel:APIModel;
		
		[MessageDispatcher]
		public var dispatcher:Function;
		
		[MessageHandler]
		public function handleMainViewComplete(event:MainViewCreationCompleteEvent):void
		{
			apiModel.wrapper = new Wrapper(FlexGlobals.topLevelApplication.parent.parent.parent);
			apiModel.privateKey = "zPEOnRmB44";
			dispatcher( new InitAPIEvent() ); 
		}
		
		[MessageHandler]
		public function readyToStart(event:AppReadyToStartEvent):void
		{
			Alert.show("123");
		}
	}
}